package com.yq.ylmall.acl.service.impl;

import com.yq.ylmall.acl.service.FileUploadService;
import com.yq.ylmall.exception.ServiceException;
import com.yq.ylmall.result.ResultCode;
import com.yq.ylmall.service.MinioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class FileUploadServiceImpl implements FileUploadService {

    @Autowired
    private MinioService minioService;

    @Override
    public String fileUpload(MultipartFile multipartFile) {
        String upload = minioService.upload(multipartFile);
        if (upload == null) {
            throw new ServiceException(ResultCode.FILE_UPLOAD_FAIL);
        }
        return upload;
    }
}
